package org.arch_learn.rpc.rmi.server;

import org.arch_learn.rpc.rmi.service.IUserService;
import org.arch_learn.rpc.rmi.service.UserService;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class RMIServer {
    public static void main(String[] args) {
        try {
            //1.注册Registry实例（注册表实例），绑定端口
            Registry registry = LocateRegistry.createRegistry(9998);
            //2.创建远程对象
            IUserService userService = new UserService();
            //3.将远程对象注册到RMI服务器上（即服务端注册表上）
            registry.rebind("userService", userService);
            System.out.println("-------RMI服务启动成功---------");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
